Does Federal Aid indicate Political Affiliation for the States?
The Federal and State levels of government are foundational aspects of the United States polictical system. While both are able to operate independtly within their jurisdiction, they still rely on each other, ideally symbiotically.
The below graphic explores how States that receive a considerable amount of fiscal aid from the Federal government, through various relief programs, and how that may correlate to their overall Democratic (Blue) or Republican (Red) affiliation.
Based on the data available, we can see that political affiliation may be correlated with greater amounts of federal aid received (calculated as a percentage of each state’s total income). There are some obvious outliers, such as New Mexico, however Red states tend to lean more on federal aid that Blue.
Code
import pandas as pdimport plotly.graph_objects as gofrom janitor import clean_namesstate_to_code = {"Alabama": "AL","Alaska": "AK","Arizona": "AZ","Arkansas": "AR","California": "CA","Colorado": "CO","Connecticut": "CT","Delaware": "DE","Florida": "FL","Georgia": "GA","Hawaii": "HI","Idaho": "ID","Illinois": "IL","Indiana": "IN","Iowa": "IA","Kansas": "KS","Kentucky": "KY","Louisiana": "LA","Maine": "ME","Maryland": "MD","Massachusetts": "MA","Michigan": "MI","Minnesota": "MN","Mississippi": "MS","Missouri": "MO","Montana": "MT","Nebraska": "NE","Nevada": "NV","New Hampshire": "NH","New Jersey": "NJ","New Mexico": "NM","New York": "NY","North Carolina": "NC","North Dakota": "ND","Ohio": "OH","Oklahoma": "OK","Oregon": "OR","Pennsylvania": "PA","Rhode Island": "RI","South Carolina": "SC","South Dakota": "SD","Tennessee": "TN","Texas": "TX","Utah": "UT","Vermont": "VT","Virginia": "VA","Washington": "WA","West Virginia": "WV","Wisconsin": "WI","Wyoming": "WY","District of Columbia": "DC",}# Load datadf = pd.read_excel("story 1.xlsx").drop("Index", axis=1)# Clean columnndf = clean_names(df)df["state_code"] = df["state"].map(state_to_code)# Create color mapping for categoriescategory_colors = {"Blue": "Blues", "Red": "Reds"}# Create separate traces for each categoryfig = go.Figure()for category in df["political_affiliation"].unique(): category_data = df[df["political_affiliation"] == category] fig.add_trace( go.Choropleth( locations=category_data["state_code"], # Uses the state code to get the graphic to render z=category_data["fed_fund_%_of_state_revenue" ], # Intensity by federal funding locationmode="USA-states", colorscale=category_colors.get(category, "Blues"), name=category, text=category_data["state"], hovertemplate="<b>%{text}</b><br>"+f"{category}<br>"+"Federal Funding: %{z:.1f}%<extra></extra>", showscale=True, colorbar=dict( title=f"{category}<br>Fed Funding %", x=1.05+ (list(df["political_affiliation"].unique()).index(category) *0.20), ), ) )fig.update_layout( title=dict( text="Federal Funding Impact on States' Polictical Affiliation", subtitle=dict( text="Federal Aid correlates but does not dictate party affiliation" ), ), geo=dict(scope="usa"), width=800, # Wider to accommodate multiple colorbars height=600,)fig.show()